Treat Enumeration as Iterator

You need a so called "Adapter", to adapt the Enumeration to the otherwise incompatible Iterator Apache commons-collections has EnumerationIterator The usage is: Iterator iterator = new EnumerationIterator(enumeration).

You need a so called "Adapter", to adapt the Enumeration to the otherwise incompatible Iterator. Apache commons-collections has EnumerationIterator. The usage is: Iterator iterator = new EnumerationIterator(enumeration).

1 on Apache Commons – vz0 Feb 15 at 17:38.

There's nothing that is part of the standard library. Unfortunately you'll have to roll your own adapter. There are examples out there of what others have done, for example: IterableEnumerator.

No need to roll your own. Look at Google's Guava library. Specifically Iterators.forEnumeration().

1 for guava. I actually thought that there was an option there too, but didn't manage to find it. – Bozho Feb 15 at 17:42.

If you can modify the class then you can simply implement Iterator too and add the remove method..

A) I'm pretty sure you mean Enumeration, not Enumerator b) Guava provides a Helper method Iterators. ForEnumeration(enumeration) that generates an iterator from an Enumeration, but that won't help you either, as you need an Iterable (a provider of Iterators), not an Iterator c) you could do it with this helper class: public class WrappingIterable implements Iterable{ private Iterator iterator; public WrappingIterable(Iterator iterator){ this. Iterator = iterator; } @Override public Iterator iterator(){ return iterator; } } And now your client code would look like this: for(String string : new WrappingIterable( Iterators.

ForEnumeration(myEnumeration))){ // your code here } But is that worth the effort?

You need a so called "Adapter", to adapt the Enumeration to the otherwise incompatible Iterator. Apache commons-collections has EnumerationIterator. B) Guava provides a Helper method Iterators.

But is that worth the effort? There's nothing that is part of the standard library.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.